﻿using BLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace L20240918s.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MemberController : ControllerBase
    {
        public MemberController(MemberBll bll) {
            Bll = bll;
        }

        public MemberBll Bll { get; }
        [HttpPost("AddMember")]
        public IActionResult AddMember([FromBody]Member member)
        {
            try
            {
               
                int add=Bll.AddMember(member);
                return Ok(new
                {
                    data=add
                });

            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet("GetMembers")]
        public IActionResult GetMembers(string? phone = "", string? name = "", DateTime? date1 = null, DateTime? date2 = null)
        {
            List<Member> list = Bll.GetMembers(phone, name, date1, date2);

            return Ok(new
            {
                data= list
            });
        }

    }
}
